﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace Jungle.Code.Core
{
    public class Debugger
    {
        #region Fields and Properties
        private static bool showSql = false;
        #endregion

        #region Public and Static methods
        public static void AddMessage(string message, MessageType type)
        {
            if (type == MessageType.SqlQuery && !showSql)
                return;

            if (HttpContext.Current.Session == null || (string)HttpContext.Current.Session["dbgMessage"] == String.Empty)
                HttpContext.Current.Session["dbgMessage"] = message;
            else
                HttpContext.Current.Session["dbgMessage"] += "<br>" + message;

        }
        public static string GetMessage()
        {
            if (HttpContext.Current.Session["dbgMessage"] != null)
                return (string)HttpContext.Current.Session["dbgMessage"];
            return String.Empty;
        }
        public static void Clear()
        {
            HttpContext.Current.Session["dbgMessage"] = String.Empty;
        }
        #endregion
    }
    public enum MessageType
    {
        Text,
        Error,
        SqlQuery
    }
}
